package followme.yaohuile.com.followme;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;

import followme.yaohuile.com.followme.fragment.CommunityFragment;
import followme.yaohuile.com.followme.fragment.DestinationFragment;
import followme.yaohuile.com.followme.fragment.RecommendFragment;


public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private ImageView ivBack,ivSearch;
    private TextView tvHeader;
    private FrameLayout frameLayout;
    private RadioGroup radioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getSupportActionBar().hide();
        initView();
        getSupportFragmentManager().beginTransaction().replace(R.id.main_frameLayout, new RecommendFragment()).commit();
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.main_rb_course:
                        getSupportFragmentManager().beginTransaction().replace(R.id.main_frameLayout, new RecommendFragment()).commit();
                        break;
                    case R.id.main_rb_zone:
                        getSupportFragmentManager().beginTransaction().replace(R.id.main_frameLayout, new DestinationFragment()).commit();
                        break;
                    case R.id.main_rb_class:
                        getSupportFragmentManager().beginTransaction().replace(R.id.main_frameLayout, new CommunityFragment()).commit();
                        break;
                    default:
                        break;
                }
            }
        });
    }
    //初始化
    private void initView() {
        ivBack = (ImageView) findViewById(R.id.ivBack);
        ivSearch = (ImageView) findViewById(R.id.ivSearch);
        tvHeader = (TextView) findViewById(R.id.tvHeader);
        frameLayout = (FrameLayout) findViewById(R.id.main_frameLayout);
        radioGroup = (RadioGroup) findViewById(R.id.main_rg);
        ivBack.setOnClickListener(this);
        ivSearch.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ivBack:
                finish();
                break;
            case R.id.ivSearch:
                break;
            default:
                break;
        }
    }
}
